package com.devframe.sysbase.model.base;

import java.io.Serializable;

import com.devframe.sysbase.model.*;

/**
 * This is an object that contains data related to the T_SYS_ROLE table.
 * Do not modify this class because it will be overwritten if the configuration file
 * related to this class is modified.
 *
 * @hibernate.class
 *  table="T_SYS_ROLE"
 */

public abstract class BaseTSysRole  implements Serializable {

	public static String REF = "TSysRole";
	public static String PROP_SORT_NO = "sortNo";
	public static String PROP_ROLE_TYPE = "roleType";
	public static String PROP_ROLE_INFO = "roleInfo";
	public static String PROP_ROLE_CODE = "roleCode";
	public static String PROP_ROLE_NAME = "roleName";


	// constructors
	public BaseTSysRole () {
		initialize();
	}

	/**
	 * Constructor for primary key
	 */
	public BaseTSysRole (java.lang.String roleCode) {
		this.setRoleCode(roleCode);
		initialize();
	}

	protected void initialize () {}



	private int hashCode = Integer.MIN_VALUE;

	// primary key
	private java.lang.String roleCode;

	// fields
	private java.lang.String roleName;
	private java.lang.String roleType;
	private java.lang.String roleInfo;
	private java.lang.Long sortNo;

	// collections
	private java.util.Set rights;

	private java.util.Set users;

	/**
	 * Return the unique identifier of this class
     * @hibernate.id
     *  generator-class="uuid.hex"
     *  column="ROLE_CODE"
     */
	public java.lang.String getRoleCode () {
		return roleCode;
	}

	/**
	 * Set the unique identifier of this class
	 * @param roleCode the new ID
	 */
	public void setRoleCode (java.lang.String roleCode) {
		this.roleCode = roleCode;
		this.hashCode = Integer.MIN_VALUE;
	}




	/**
	 * Return the value associated with the column: ROLE_NAME
	 */
	public java.lang.String getRoleName () {
		return roleName;
	}

	/**
	 * Set the value related to the column: ROLE_NAME
	 * @param roleName the ROLE_NAME value
	 */
	public void setRoleName (java.lang.String roleName) {
		this.roleName = roleName;
	}



	/**
	 * Return the value associated with the column: ROLE_TYPE
	 */
	public java.lang.String getRoleType () {
		return roleType;
	}

	/**
	 * Set the value related to the column: ROLE_TYPE
	 * @param roleType the ROLE_TYPE value
	 */
	public void setRoleType (java.lang.String roleType) {
		this.roleType = roleType;
	}



	/**
	 * Return the value associated with the column: ROLE_INFO
	 */
	public java.lang.String getRoleInfo () {
		return roleInfo;
	}

	/**
	 * Set the value related to the column: ROLE_INFO
	 * @param roleInfo the ROLE_INFO value
	 */
	public void setRoleInfo (java.lang.String roleInfo) {
		this.roleInfo = roleInfo;
	}



	/**
	 * Return the value associated with the column: SORT_NO
	 */
	public java.lang.Long getSortNo () {
		return sortNo;
	}

	/**
	 * Set the value related to the column: SORT_NO
	 * @param sortNo the SORT_NO value
	 */
	public void setSortNo (java.lang.Long sortNo) {
		this.sortNo = sortNo;
	}



	/**
	 * Return the value associated with the column: rights
	 */
	public java.util.Set getRights () {
		return rights;
	}

	/**
	 * Set the value related to the column: rights
	 * @param rights the rights value
	 */
	public void setRights (java.util.Set rights) {
		this.rights = rights;
	}

	public void addTorights (TSysRoleRights tSysRoleRights) {
		if (null == getRights()) setRights(new java.util.TreeSet());
		getRights().add(tSysRoleRights);
	}




	public boolean equals (Object obj) {
		if (null == obj) return false;
		if (!(obj instanceof TSysRole)) return false;
		else {
			TSysRole tSysRole = (TSysRole) obj;
			if (null == this.getRoleCode() || null == tSysRole.getRoleCode()) return false;
			else return (this.getRoleCode().equals(tSysRole.getRoleCode()));
		}
	}

	public int hashCode () {
		if (Integer.MIN_VALUE == this.hashCode) {
			if (null == this.getRoleCode()) return super.hashCode();
			else {
				String hashStr = this.getClass().getName() + ":" + this.getRoleCode().hashCode();
				this.hashCode = hashStr.hashCode();
			}
		}
		return this.hashCode;
	}


	public String toString () {
		return super.toString();
	}

	public java.util.Set getUsers() {
		return users;
	}

	public void setUsers(java.util.Set users) {
		this.users = users;
	}
	
	public void addTousers (TSysUserRole tSysUserRole) {
		if (null == getUsers()) setUsers(new java.util.TreeSet());
		getUsers().add(tSysUserRole);
	}


}